package com.rongke.service.impl;

import java.util.List;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.rongke.mapper.ChemotherapyMapper;
import com.rongke.model.Chemotherapy;
import com.rongke.service.ChemotherapyService;

import org.springframework.stereotype.Service;

/**
 * @ChemotherapyServiceImpl
 * @化疗方案ServiceImpl
 * @version : Ver 1.0
 */
@Service
public class ChemotherapyServiceImpl extends ServiceImpl<ChemotherapyMapper, Chemotherapy>
                                                                                          implements
                                                                                          ChemotherapyService {

    @Override
    public List<Chemotherapy> selectByMrId(long mrId) {
        EntityWrapper<Chemotherapy> ew = new EntityWrapper<>();
        ew.eq("medical_record_id", mrId);
        ew.orderBy("start_date");

        return baseMapper.selectList(ew);
    }

    @Override
    public List<Chemotherapy> selectByMrIdAndDate(long mrId, String startDate) {
        EntityWrapper<Chemotherapy> ew = new EntityWrapper<>();
        ew.eq("medical_record_id", mrId);
        ew.ge("start_date", startDate);
        ew.orderBy("start_date", false);

        return baseMapper.selectList(ew);
    }

    @Override
    public List<Chemotherapy> selectByMrIdAndDateRange(long mrId, String startDate, String endDate) {
        EntityWrapper<Chemotherapy> ew = new EntityWrapper<>();
        ew.eq("medical_record_id", mrId);
        ew.ge("start_date", startDate);
        ew.le("start_date", endDate);
        ew.orderBy("start_date", false);

        return baseMapper.selectList(ew);
    }
}
